/*
 * Title:        CloudScheduler Toolkit
 * Description:  a Toolkit for Modeling and Simulation of Job Scheduling and Resource Provisioning in Cloud System
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 * Author:       Fuhui Wu
 *
 * Copyright (c) 2013-2014, The National University of Defense Technology, China
 */

package org.nudt.jCloud.workflow;

import java.util.Iterator;

import org.jgrapht.graph.DefaultDirectedWeightedGraph;
import org.jgrapht.graph.DefaultWeightedEdge;

public class Workflow {
	private DefaultDirectedWeightedGraph<Node, DefaultWeightedEdge> DAG;
	private Node entryNode;
	private Node exitNode;
	
	public Workflow(){
		entryNode = new Node("entry", 0);
		exitNode = new Node("exit", 0);
		DAG = new DefaultDirectedWeightedGraph<Node,
				DefaultWeightedEdge>(DefaultWeightedEdge.class);
		DAG.addVertex(entryNode);
		DAG.addVertex(exitNode);
	}
	
	public Node getNode(String id){
		for(Iterator<Node> itr = DAG.vertexSet().iterator(); itr.hasNext(); ){
			Node node = itr.next();
			if(node.getId().equals(id)){
				return node;
			}
		}
		return null;
	}
	
	public Node getEntryNode() {
		return entryNode;
	}

	public void setEntryNode(Node entryNode) {
		this.entryNode = entryNode;
	}

	public Node getExitNode() {
		return exitNode;
	}

	public void setExitNode(Node exitNode) {
		this.exitNode = exitNode;
	}

	public DefaultDirectedWeightedGraph<Node, DefaultWeightedEdge> getDAG() {
		return DAG;
	}

	public void setDAG(DefaultDirectedWeightedGraph<Node, DefaultWeightedEdge> dAG) {
		DAG = dAG;
	}

}
